Task Based Help > Loading a Report into the C1DocumentViewer Control |
To load a report into the C1DocumentViewer control, just set the C1DocumentViewer.FileName and C1DocumentViewer.ReportName properties. You can do so in the designer, in code or in XAML:
In the Designer
To load a report in the designer, complete the following steps:
The reports available in the reports file should now appear in the C1DocumentViewer.ReportName drop-down box.
In Code
Set theC1DocumentViewer.FileName and C1DocumentViewer.ReportName properties to the appropriate report definition location and report name in code. For example, add the following code to the Page_Load event to load the CommonTasks.xml report definition file into the C1DocumentViewer control:
Visual Basic |
Copy Code
|
---|---|
C1DocumentViewer1.FileName = "C:\Documents and Settings\<username>\My Documents\ComponentOne Samples\C1WPFReport\C1Report\Samples\XML\CommonTasks\CommonTasks.xml" C1DocumentViewer1.ReportName = "01: Alternating Background (Greenbar report)" |
C# |
Copy Code
|
---|---|
C1DocumentViewer1.FileName = "@C:\Documents and Settings\<username>\My Documents\ComponentOne Samples\C1WPFReport\C1Report\Samples\XML\CommonTasks\CommonTasks.xml"; C1DocumentViewer1.ReportName = "01: Alternating Background (Greenbar report)"; |
Note: Update the directory in the code above with the correct samples installation directory on your machine. |
In XAML
Set theC1DocumentViewer.FileName and C1DocumentViewer.ReportName properties to the appropriate report definition location and report name in the <my:C1DocumentViewer> tag. For example, use the following XAML to load the CommonTasks.xml report definition file into the C1DocumentViewer control:
<my:C1DocumentViewer Name="C1DocumentViewer1" FileName="C:\Documents and Settings\<username>\My Documents\ComponentOne Samples\C1WPFReport\C1Report\Samples\XML\CommonTasks\CommonTasks.xml" ReportName="01: Alternating Background (Greenbar report)"></my:C1DocumentViewer>
Note: Update the directory in the code above with the correct samples installation directory on your machine. |
Run your application and observe:
The 01: Alternating Background (Greenbar report) report has been loaded in the C1DocumentViewer control: